package cn.bluethink.eguan.rewardtask.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import cn.bluethink.eguan.model.core.EgFile;
import cn.bluethink.eguan.model.core.EgResult;
import cn.bluethink.eguan.model.core.EgUser;
import cn.bluethink.eguan.model.rewardtask.EgReceiver;
import cn.bluethink.eguan.model.rewardtask.EgRewardTask;

/**
 * 悬赏任务+接收者联合查询的返回结果
 * 
 * @author 苏州中科蓝迪公司所有(c)2016-2021
 * @version 0.1.0
 * @note 修订历史： 1、wanglei于2018/10/23设计并构建初始版本v0.1.0
 */
public class ReceiverEntity implements Serializable {

    private static final long serialVersionUID = -831972160984935658L;

    // 揭榜人Id
    private Long id;
    
    // 悬赏任务id
    private Long tid;

    // 接收者的id
    private Long uid;

    // 接受者的状态
    private Integer status;

    // 揭榜时间
    private Date btime;

    // 任务完成时间
    private Date etime;

    // 任务的完成结果
    private Long resultOid;

    // 任务结果描述
    private String resultDes;

    // 结果提交的时间
    private Date subTime;

    // 奖励的任务赏金
    private Integer reward;

    // 接收者的头像
    private String avator;

    // 接收者的名称
    private String uname;

    /*
     * 实体模型转业务模型
     */
    public EgReceiver createReceiver() {

        EgReceiver receiver = new EgReceiver();
        receiver.setId(id);
        // 设置接收任务的用户
        receiver.setUser(new EgUser(uid, uname, avator));
        receiver.setStatus(status);
        receiver.setBtime(btime);
        receiver.setEtime(etime);

        if (reward != null && reward > 0) {
            receiver.setReward(reward);
        } else {
            receiver.setReward(0);
        }
        // 设置领取者所领取的悬赏任务
        EgRewardTask task = new EgRewardTask(tid, null, null);
        receiver.setTask(task);
        // 设置任务完成的结果
        EgResult result = new EgResult();
        List<EgFile> fileList = new ArrayList<>();
        if (resultOid != null && resultOid > 0) {
            result.setId(resultOid);
        }
        result.setFileList(fileList);
        receiver.setResult(result);
        receiver.setSubTime(subTime);
        return receiver;
    }

    public Long getTid() {
        return tid;
    }

    public void setTid(Long tid) {
        this.tid = tid;
    }

    public Long getUid() {
        return uid;
    }

    public void setUid(Long uid) {
        this.uid = uid;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Date getBtime() {
        return btime;
    }

    public void setBtime(Date btime) {
        this.btime = btime;
    }

    public Date getEtime() {
        return etime;
    }

    public void setEtime(Date etime) {
        this.etime = etime;
    }

    public Long getResultOid() {
        return resultOid;
    }

    public void setResultOid(Long resultOid) {
        this.resultOid = resultOid;
    }

    public Integer getReward() {
        return reward;
    }

    public void setReward(Integer reward) {
        this.reward = reward;
    }

    public String getAvator() {
        return avator;
    }

    public void setAvator(String avator) {
        this.avator = avator;
    }

    public String getUname() {
        return uname;
    }

    public void setUname(String uname) {
        this.uname = uname;
    }

    public Date getSubTime() {
        return subTime;
    }

    public void setSubTime(Date subTime) {
        this.subTime = subTime;
    }

    public String getResultDes() {
        return resultDes;
    }

    public void setResultDes(String resultDes) {
        this.resultDes = resultDes;
    }

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

}
